/**Doctor presenter**/
// $codepro.audit.disable staticInstantiation, variableUsage
package edu.gatech.presenters;

import javax.swing.JOptionPane;

import edu.gatech.datastorage.TreatmentRecord;
import edu.gatech.gui.EditPatientPanel;
import edu.gatech.gui.MedicalHistoryPanel;
import edu.gatech.gui.TreatmentRecordPanel;
import edu.gatech.userclasses.Doctor;
import edu.gatech.userclasses.Patient;

/**Class that sets up the Doctor GUI
 * 
 * @author Tyler Natoli
 * @version 1.0
 */
public class DoctorPresenter {
	
	/**Doctor that logs in**/
	private final Doctor currentDoctor;
	
	/**Parameter that gets doctor from the GUI
	 * 
	 * @param currentDoctor
	 */
	public DoctorPresenter(Doctor currentDoctor){
		this.currentDoctor = currentDoctor;
	}
	
	/**Views the reports of a patient
	 * 
	 * @param patientName
	 */
	public void viewReports(String patientName){
		final Patient patient;
		patient = currentDoctor.searchForPatient(patientName);
		if(patient != null){
			final MedicalHistoryPanel panel = new MedicalHistoryPanel(patient);
		}
		else{
			JOptionPane.showMessageDialog(null, "Patient was not found");
		}
	}
	
	/**Adds doctors orders to a patients
	 * treatment record
	 * 
	 * @param patientName
	 */
	public void addOrders(String patientName){
		final Patient patient;
		patient = currentDoctor.searchForPatient(patientName);
		if(patient != null){
			final TreatmentRecord record = patient.getInfo().getLastRecord();
			if(record != null){
				final TreatmentRecordPanel panel = 
					new TreatmentRecordPanel(patient, currentDoctor);
			}
			else{
				JOptionPane.showMessageDialog(null, 
						"Patient does not have a treatment record on file");
			}
		}
		else{
			JOptionPane.showMessageDialog(null, "Patient was not found");
		}
	}
	
	/**
	 * Searches for a patient
	 * @param patientName
	 */
	public void search(String patientName){
		final Patient patient = currentDoctor.searchForPatient(patientName);
		if(patient != null){
			final EditPatientPanel editPanel = 
				new EditPatientPanel(patient, currentDoctor);
		}
		else{
			JOptionPane.showMessageDialog(null, "Patient not found");
		}
	}
	
	/**Overrides toString
	 * @return String
	 */
	public String toString(){
		return "Doctor presenter";
	}
}
